<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>岗位情况</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<div class="container-fluid">
    <!--    成功-->
    <div th:if="${success}" class="alert alert-success" role="alert">
        <strong>成功!</strong><span th:text="${successMsg}"></span>
    </div>
    <!--    error-->
    <div th:if="${error}" class="alert alert-danger" role="alert">
        <strong>错误!</strong><span th:text="${errorMsg}"></span>
    </div>
    <!--    标题-->
    <h1 th:if="${changCi}" th:text="${changCi.name}"></h1>
    <!--  工具栏-->
    <div class="row">
        <div class="col-md-6">
        </div>
        <div class="col-md-6 text-right">
            <a th:href="@{/job/download}" class="btn btn-primary">模板下载</a>
            <a th:href="@{/job/import(changCiId=${changCi.id})}" class="btn btn-primary">岗位导入</a>
<!--            <a th:href="@{/job/deleteAllJob(changCiId=${changCi.id})}" class="btn btn-danger">岗位删除</a>-->
            <a th:href="@{/job/statistics/region-degree(changCiId=${changCi.id})}" class="btn btn-success">归属-学历-岗位统计</a>
            <a th:href="@{/job/statistics/subject-stage(changCiId=${changCi.id})}" class="btn btn-success">学科-学段-岗位统计</a>
        </div>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th>序号</th>
                <th>招聘单位</th>
                <th>镇街/直属</th>
                <th>岗位名称</th>
                <th>所属学段</th>
                <th>岗位代码</th>
                <th>招聘人数</th>
                <th>招聘对象</th>
                <th>学历</th>
                <th>学位</th>
                <th>其他条件</th>
                <th>考点</th>
                <th>招聘单位联系方式</th>
                <th>学科</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="job : ${jobs}">
                <td th:text="${job.sort}"></td>
                <td th:text="${job.company}"></td>
                <td th:text="${job.region}"></td>
                <td th:text="${job.jobName}"></td>
                <td th:text="${job.stage}"></td>
                <td th:text="${job.code}"></td>
                <td th:text="${job.count}"></td>
                <td th:text="${job.target}"></td>
                <td th:text="${job.degree}"></td>
                <td th:text="${job.degreeLevel}"></td>
                <td th:text="${job.other}"></td>
                <td th:text="${job.address}"></td>
                <td th:text="${job.contact}"></td>
                <td th:text="${job.subject}"></td>
            </tr>
            </tbody>
        </table>
    </div>

    <div class="text-center">
        <ul class="pagination">
            <li th:class="${currentPage == 1} ? 'disabled'">
                <a type="button" th:href="@{/job/list(page=1,changCiId=${changCi.id})}">首页</a>
            </li>

            <!-- 显示第一页 -->
            <li th:class="${currentPage == 1} ? 'active'">
                <a th:href="@{/job/list(page=1,changCiId=${changCi.id})}">1</a>
            </li>

            <!-- 前省略号：当左边有隐藏页码时显示 -->
            <li th:if="${currentPage - 3 > 1}" class="disabled">
                <span>...</span>
            </li>

            <!-- 中间页码生成逻辑（1-based） -->
            <li th:each="page : ${#numbers.sequence(
            (totalPages <= 5) ? 2 : (currentPage > 3 ? currentPage - 2 : 2),
            (totalPages <= 5) ? (totalPages - 1) : (currentPage < (totalPages - 2) ? currentPage + 2 : totalPages - 1)
        )}"
                th:class="${page == currentPage} ? 'active'"
                th:if="${totalPages > 1}">
                <a th:href="@{/job/list(page=${page},changCiId=${changCi.id})}" th:text="${page}"></a>
            </li>

            <!-- 后省略号：当右边有隐藏页码时显示 -->
            <li th:if="${currentPage + 3 < totalPages}" class="disabled">
                <span>...</span>
            </li>

            <!-- 显示最后一页（总页数>1时显示） -->
            <li th:if="${totalPages > 1}" th:class="${currentPage == totalPages} ? 'active'">
                <a th:href="@{/job/list(page=${totalPages},changCiId=${changCi.id})}" th:text="${totalPages}"></a>
            </li>

            <li th:class="${currentPage == totalPages} ? 'disabled'">
                <a type="button" th:href="@{/job/list(page=${totalPages},changCiId=${changCi.id})}">尾页</a>
            </li>
        </ul>
    </div>
</div>
</body>
</html>